package strts.from;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

import bean.BaseBean;


/**
 * 表单参数生成类
 * @author dr
 *
 */
public class FullForm {

	/**
	 * 根据requst参数转化成表单数
	 * @param beanClassStr
	 * @param request
	 * @return
	 */
	public static BaseBean full(String beanClassStr,HttpServletRequest request){
		BaseBean form=null;
		 try {
			//将BeanClass通过反射原理，创建Form对象
			Class clazz = Class.forName(beanClassStr);
			form = (BaseBean)clazz.newInstance();
			Field[]  field=clazz.getDeclaredFields();//获取所有属性
			
			//对属性赋值，用页面传过来的值账值
			for(Field f:field){
				f.setAccessible(true);
				f.set(form,request.getParameter(f.getName()));
				f.setAccessible(false);
				
			}
			
			
			
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("严重");
		}
		 
		 
		 
		 
		 return form;
		
	}
}
